package com.seanbot.armstrong.poolgame;


import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.util.AttributeSet;
import android.view.SurfaceHolder;
import android.view.SurfaceView;


public class PoolView extends SurfaceView implements SurfaceHolder.Callback{

	private Ball ball = null;
	BallThread thread;
	

	public PoolView(Context context, AttributeSet attrs) {
		super(context);
		ball = new Ball(100, 150);

		thread = new BallThread(this);
		thread.startThread();
	}

	public void onDraw(Canvas canvas) {
		canvas.drawColor(Color.WHITE);
		ball.draw(canvas);
	}

	public void moveCircle() {
		ball.checkBounds(getWidth(), getHeight());
		ball.move();
	}

	public void surfaceChanged(SurfaceHolder arg0, int arg1, int arg2, int arg3) {
		// TODO Auto-generated method stub
		
	}

	public void surfaceCreated(SurfaceHolder holder) {
		// TODO Auto-generated method stub
		
	}

	public void surfaceDestroyed(SurfaceHolder holder) {
		// TODO Auto-generated method stub
		
	}
	
	
}

//	
//	private BallThread thread;
//	
//	public PoolView(Context context, AttributeSet attrs) {
//		super(context, attrs);
//		getHolder().addCallback(this);
//		
//		thread = new BallThread(getHolder(), this);
//		
//		setFocusable(true);
//	}
//
//	public void surfaceChanged(SurfaceHolder holder, int format, int width,
//			int height) {
//		
//	}
//
//	public void surfaceCreated(SurfaceHolder holder) {
//		thread.setRunning(true);
//		thread.start();
//	}
//
//	public void surfaceDestroyed(SurfaceHolder holder) {
//		boolean retry = true;
//		while (retry) {
//			try {
//				thread.join();
//				retry = false;
//			} catch (InterruptedException e){
//				
//			}
//		}
//	}
//	
//	public boolean onTouchEvent(MotionEvent event) {
//		return super.onTouchEvent(event);
//	}
//	
//	public void onDraw(Canvas canvas) {
//		Paint paint = new Paint();
//		canvas.drawCircle(20, 20, 30, paint);
//	}
//	
//}
